package com.chs.app;

import com.chs.dao.AgeMoneyDAO;
import com.chs.dao.ClickNumDAO;
import com.chs.domain.AgeMoney;
import com.chs.domain.ClickNum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * web层
 */
@RestController
public class StartApp {


    @Autowired
    AgeMoneyDAO ageMoneyDAO;

    @Autowired
    ClickNumDAO clickNumDAO;



    @RequestMapping(value = "/age_money", method = RequestMethod.POST)
    @ResponseBody
    public List<AgeMoney> courseAgeMoney() throws Exception {

        List<AgeMoney> list = ageMoneyDAO.query("age::money");
        for(AgeMoney model : list) {
//            model.setName(courses.get(model.getName().substring(9)));
            System.out.println(model.getAge()+":"+model.getMoney());
        }

        return list;
    }

    @RequestMapping(value = "/click_num", method = RequestMethod.POST)
    @ResponseBody
    public List<ClickNum> courseCLickNUm() throws Exception {

        List<ClickNum> list = clickNumDAO.query("pid::click");
        for(ClickNum model : list) {
            System.out.println(model.getPid()+":"+model.getClickValue());
        }

        return list;
    }



    @RequestMapping(value = "/analysis", method = RequestMethod.GET)
    public ModelAndView echarts1(){
        return new ModelAndView("analysis");
    }

}
